<!--
 * @Description: history
 * @Author: rendc
 * @Date: 2022-06-14 08:42:58
 * @LastEditors: rendc
 * @LastEditTime: 2022-06-14 08:50:54
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>history</title>
</head>

<body>
  history
  <br>
  <button onclick="go()">
    前进一页
  </button>
  <br>
  <button onclick="back()">
    后退一页
  </button>
  <button onclick="myGo(-2)">
    后退两页
  </button>
  <button onclick="goBaidu()">
    跳转到百度
  </button>
</body>
<script>
  function myGo(num) {
    history.go(num)
  }

  function go() {
    // history.go(1)
    history.forward()
  }

  function back() {
    // history.go(-1)
    history.back()
  }

  function goBaidu() {
    window.location = "http://baidu.com"
  }
</script>

</html>